package com.litbw.event;

import com.litbw.event.Contest;
import com.litbw.event.Contest.Entry;
//User class needs to be defined for this class to work.
import com.litbw.user.*;

import java.util.ArrayList;
import java.util.ArrayList;



/**
 * Event class representing a weaving event
 * 
 * @author Silvia Chita
 * @version Feb 13, 2013
 */
public class Event {
	private ArrayList<Entry> entries;
	private ArrayList<User> registrants;
	private ArrayList<Contest> categories;
	private String location;
	private String date;
	private String description;
	private int time;
	private int id;
	
	/**
	 * Constructor for an event.
	 */
	public Event() {
		entries = new ArrayList<Entry>();
		registrants = new ArrayList<User>();
		categories = new ArrayList<Contest>();
	}
	
	public void setId(final int id) {
		this.id = id;
	}
	
	public int getId() {
		return id;
	}
	
	/**
	 * @return A copy of the list of entries.
	 */
	public ArrayList<Entry> getEntries() {
		return (ArrayList<Entry>) entries.clone();
	}
	
	/**
	 * @return A copy of the list of registrants.
	 */
	public ArrayList<User> getRegistrants() {
		return (ArrayList<User>) registrants.clone();
	}
	
	/**
	 * @return A copy of the list of categories of the event.
	 */
	public ArrayList<Contest> getCategories() {
		return (ArrayList<Contest>) categories.clone();
	}
	
	/**
	 * @return A string for the location of the event
	 */
	public String getLocation() {
		return location;
	}
	
	/**
	 * @return A string for the date of the event.
	 */
	public String getDate() {
		return date;
	}
	
	/**
	 * @return A string for the description of the event.
	 */
	public String getDescription() {
		return description;
	}
	
	/**
	 * @return the time of the event as its military representation.
	 */
	public int getTime() {
		return time;
		/*
		 * this code will be used in coverting the time as the event uses it to a 
		 * String that can easily be displayed.
		 * 
		StringBuilder sb = new StringBuilder();
		int h = time / 100;
		int m = time % 100;
		boolean pm = false;
		if (h >= 12) {
			pm = true;
			if (h != 12) {
				h -= 12;
			}
		}
		sb.append(h);
		sb.append(":");
		sb.append(m);
		if (pm) {
			sb.append(" pm");
		} else {
			sb.append(" am");
		}
		return sb.toString();
		*/
	}
	
	/**
	 * @param newDate The new date to be set
	 */
	public void setDate(String newDate) {
		date = newDate;
	}
	
	/**
	 * @param newLoc The new location to be set
	 */
	public void setLocation(String newLoc) {
		location = newLoc;
	}
	
	/**
	 * @param newDescrip The new description to be set
	 */
	public void setDescription(String newDescrip) {
		description = newDescrip;
	}
	
	/**
	 * @param militaryTime The integer representation of the time as military time
	 * 						to be set
	 */
	public void setTime(int militaryTime) {
		time = militaryTime;
	}

	/**
	 * @param entry The entry to be added
	 * @param category The category to which it is added.
	 */
	public void addEntry(Entry entry, Contest category) {
		entries.add(entry);
		//TODO: figure out how contests and entries relate. map?
		category.addEntry(entry);
	}
	
	/**
	 * Method to add a registrant
	 * @param user The user to be added as a registrant to an event.
	 */
	public void addRegistrant(User user) {
		registrants.add(user);
	}
	
	/**
	 * Method to add a contest category to an event
	 * @param category The new category of a contest to be added to this event.
	 */
	public void addCategory(Contest category) {
		categories.add(category);
	}
}
